package com.yxp423.ssmempl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yxp423.ssmempl.bean.Notify;
import com.yxp423.ssmempl.bean.User;
import com.yxp423.ssmempl.dto.NotifyDto;
import com.yxp423.ssmempl.mapper.NotifyMapper;
import com.yxp423.ssmempl.service.INotifyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: java类作用描述
 * @Author: yxp
 * @CreateDate: 2019-06-13 11:18
 * @Version: 1.0
 */

@Slf4j
@Service
public class NotifyServiceImpl implements INotifyService {

	@Autowired
	NotifyMapper notifyMapper;

	@Override
	public int saveNotify(NotifyDto notifyDto,User user) {

		int flag = -1;
		try {

			Notify notify = new Notify();
			BeanUtil.copyProperties(notifyDto,notify);
			notify.setCreateId(user.getUserId().toString());
			notify.setCreateTime(DateUtil.date());

			flag = notifyMapper.insert(notify);

		} catch (Exception e) {

			log.error("发生错误{}",e.getMessage());

		}

		return flag;
	}

	@Override
	public Page<Notify> getNotifys() {
		return null;
	}
}
